<template>
  <div class="dist-container">
    <div>
      超过<el-input
        :step="1"
        @blur="updateConfig"
        v-model="outtime"
        type="number"
      />分钟, 自动分配到该站点的<span>在线状态</span>的平台跑腿员;
    </div>
     <div>
      接单截止前<el-input
        :step="1"
        @blur="updateConfig"
        v-model="autoCancel"
        type="number"
      />分钟没有可分配的在线平台赏金猎人且无人接单，将自动取消订单，并消息提醒用户;
    </div>
    <div>
      订单配送超时<el-input
        :step="1"
        @blur="updateConfig"
        v-model="autoMin"
        type="number"
      />分钟进行消息提醒
    </div>
  </div>
</template>

<script>
import { query, update } from "@/api/system/dist";
import gdMap from "@/components/gd-map";

export default {
  name: "User",
  components: {
    gdMap,
  },
  data() {
    return {
      autoMin: 0,
      autoCancel: 0,
      outtime: 0,
    };
  },
  created() {
    this.getData();
  },
  methods: {
    updateConfig() {
      update({
        autoMin: Number(this.autoMin),
        outtime: Number(this.outtime),
        autoCancel: Number(this.autoCancel),
      }).then((res) => {
        if(res.code === 200) {
          this.msgSuccess('修改成功')
        } else {
          this.msgError(res.message || '修改失败')
        }
      });
    },
    getData() {
      query().then((res) => {
        this.autoMin = res.data.autoMin;
        this.outtime = res.data.outtime;
        this.autoCancel = res.data.autoCancel;
      });
    },
  },
};
</script>

<style type="text/css" lang="scss" scoped>
.dist-container {
  padding: 20px;
  font-size: 16px;
  & > div {
    margin-bottom: 12px;
  }
  span {
    color: rgb(199, 123, 9);
  }
  .el-input {
    width: 100px;
    margin: 0 15px;
  }
}
</style>
